var __extends =
    (this && this.__extends) ||
    (function () {
      var a = function (e, i) {
        return (a =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (a, e) {
              a.__proto__ = e;
            }) ||
          function (a, e) {
            for (var i in e)
              Object.prototype.hasOwnProperty.call(e, i) && (a[i] = e[i]);
          })(e, i);
      };
      return function (e, i) {
        function n() {
          this.constructor = e;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        a(e, i),
          (e.prototype =
            null === i
              ? Object.create(i)
              : ((n.prototype = i.prototype), new n()));
      };
    })(),
  FactionManagerView = (function (a) {
    function e() {
      var e = a.call(this) || this;
      return (
        e.btn_fac_manager_back.on(Laya.Event.CLICK, e, e.onDidClickClose),
        (e.list_fac_yaoqing.vScrollBarSkin = ""),
        (e.list_fac_yaoqing.selectEnable = !0),
        e.list_fac_yaoqing.on(Laya.Event.CLICK, e, e.onDidClickYaoQingAction),
        (e.list_fac_yaoqing.renderHandler = new Laya.Handler(
          e,
          e.onRenderFacYaoQingItem
        )),
        (e.list_fac_yaoqing.scrollBar.changeHandler = new Handler(
          e,
          e.onLoadMoreJiaoPaiData
        )),
        e.btn_fac_rubangdengji.on(
          Laya.Event.CLICK,
          e,
          e.onDidClickRuBangDengjiAction
        ),
        e.btn_fac_yaoqingjiangli.on(
          Laya.Event.CLICK,
          e,
          e.onDidClickRYaoQingJiangLiAction
        ),
        e.tab_fac_bangpaichengyuan.on(
          Laya.Event.CLICK,
          e,
          e.onTabChengyuanDidClick
        ),
        (e.list_bangpai_chengyuan.vScrollBarSkin = ""),
        (e.list_bangpai_chengyuan.selectEnable = !0),
        e.list_bangpai_chengyuan.on(
          Laya.Event.CLICK,
          e,
          e.onDidClickChengYuanDetailAction
        ),
        (e.list_bangpai_chengyuan.renderHandler = new Laya.Handler(
          e,
          e.onRenderFacChengYuanItem
        )),
        (e.list_bangpai_chengyuan.scrollBar.changeHandler = new Handler(
          e,
          e.onLoadMoreChengYuanData
        )),
        WebSocketService.addListener({
          caller: e,
          code: 1901,
          method: e.onLoadBangPaiApplyManagerFn,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 1211,
          method: e.onLoadBangPaiManagerResultFn,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 1218,
          method: e.onLoadBangPaiChengYuanResultFn,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 1219,
          method: e.onLoadBangPainMemDengJiFn,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 1126,
          method: e.onLoadMySelfBangpaiDataFn,
        }),
        Laya.stage.on("FactionManagerView", e, e.eventHandler),
        e
      );
    }
    return (
      __extends(e, a),
      (e.showFacManagerView = function (a) {
        return (
          null == this.facManagerV && (this.facManagerV = new e()),
          (this.facManagerV.type = a),
          (this.facManagerV.listArr = []),
          "yaoqing" == a
            ? ((this.facManagerV.image_fac_bangpaiyaoqing.visible = !0),
              (this.facManagerV.image_fac_mangager_setting.visible = !0),
              (this.facManagerV.image_fac_bangpaichengyuan.visible = !1),
              (this.facManagerV.label_fac_bangpai_minLvl.text =
                "不低于" + Global.bangpaiMinLvl + "级"),
              (this.facManagerV.list_fac_yaoqing.visible = !1),
              Global.bangpaiID < 0 || null == Global.bangpaiID
                ? (this.facManagerV.image_fac_mangager_setting.visible = !1)
                : (WebSocketService.send({
                    c: 1901,
                    d: { id: Global.bangpaiID, pageNum: 0 },
                  }),
                  (this.facManagerV.image_fac_mangager_setting.visible = !0)),
              3 == Global.bangpaiMem || 4 == Global.bangpaiMem
                ? ((this.facManagerV.btn_fac_rubangdengji.visible = !0),
                  (this.facManagerV.btn_fac_yaoqingjiangli.visible = !0))
                : ((this.facManagerV.btn_fac_rubangdengji.visible = !1),
                  (this.facManagerV.btn_fac_yaoqingjiangli.visible = !1)))
            : ((this.facManagerV.image_fac_bangpaiyaoqing.visible = !1),
              (this.facManagerV.image_fac_mangager_setting.visible = !1),
              (this.facManagerV.image_fac_bangpaichengyuan.visible = !0),
              (this.facManagerV.tab_fac_bangpaichengyuan.selectedIndex = 0),
              WebSocketService.send({
                c: 1218,
                d: { id: Global.bangpaiID, pageNum: 0 },
              })),
          this.facManagerV
        );
      }),
      (e.prototype.onLoadBangPaiApplyManagerFn = function (a) {
        if (0 == a.code) {
          if (this.currentPage >= 1) {
            if (0 == a.list.length) return void this.currentPage--;
            for (n = 0; n < a.list.length; n++) {
              var e = a.list[n];
              this.listArr.push(e), (this.dataSource = []);
            }
          } else (this.listArr = a.list), (this.dataSource = []);
          (this.isloading = !1), (this.list_fac_yaoqing.visible = !0);
          for (var i, n = 0; n < this.listArr.length; n++) {
            var t = this.listArr[n];
            (i = {
              label_yaoqing_name: {
                text: t.l + "级 " + Dictionary.roleType[t.t] + "  " + t.n,
              },
              btn_yaoqing_sure: { label: "同意" },
              btn_yaoqing_reject: { label: "拒绝" },
            }),
              this.dataSource.push(i);
          }
          this.list_fac_yaoqing.dataSource = this.dataSource;
        }
      }),
      (e.prototype.onRenderFacYaoQingItem = function (a, e) {
        if (!(e > this.list_fac_yaoqing.length)) {
          var i = a.getChildByName("btn_yaoqing_reject"),
            n = a.getChildByName("btn_yaoqing_sure"),
            t = Global.bangpaiMem;
          3 == t || 4 == t
            ? ((i.visible = !0), (n.visible = !0))
            : ((i.visible = !1), (n.visible = !1));
        }
      }),
      (e.prototype.onRenderFacChengYuanItem = function (a, e) {
        if (!(e > this.list_bangpai_chengyuan.length)) {
          var i = a.getChildByName("label_online"),
            n =
              (a.getChildByName("label_chengyuan_msg"),
              a.getChildByName("btn_bangpai_caozuo"));
          if (
            (1 == this.listArr[e].o
              ? ((i.visible = !0), (i.color = "#13f31c"))
              : ((i.visible = !1), (i.color = "#ffffff")),
            3 == Global.bangpaiMem || 4 == Global.bangpaiMem)
          ) {
            n.visible = !0;
            this.listArr[e].id == Global.roleId && (n.visible = !1);
          } else n.visible = !1;
          var t = this.listArr[e];
          (-1 == t.t.indexOf("主") && -1 == t.t.indexOf("法")) ||
            (n.visible = !1);
        }
      }),
      (e.prototype.onLoadMoreJiaoPaiData = function (a) {
        var e = a / this.list_fac_yaoqing.scrollBar.max,
          i = new Date(),
          n = !1;
        if (
          (i.getTime() - this.spaceTime >= 3e3 && (n = !0),
          1 == e && 0 == this.isloading && n)
        )
          return (
            (this.isloading = !0),
            this.currentPage++,
            WebSocketService.send({
              c: 1901,
              d: { id: Global.bangpaiID, pageNum: this.currentPage },
            }),
            void (this.spaceTime = i.getTime())
          );
      }),
      (e.prototype.onLoadMoreChengYuanData = function (a) {
        var e = a / this.list_bangpai_chengyuan.scrollBar.max,
          i = new Date(),
          n = !1;
        if (
          (i.getTime() - this.spaceTime >= 3e3 && (n = !0),
          1 == e && 0 == this.isloading && n)
        )
          return (
            (this.isloading = !0),
            this.currentPage++,
            0 == this.tab_fac_bangpaichengyuan.selectedIndex
              ? WebSocketService.send({
                  c: 1218,
                  d: { id: Global.bangpaiID, pageNum: this.currentPage },
                })
              : 1 == this.tab_fac_bangpaichengyuan.selectedIndex
              ? WebSocketService.send({
                  c: 1219,
                  d: {
                    id: Global.bangpaiID,
                    type: 1,
                    pageNum: this.currentPage,
                  },
                })
              : 2 == this.tab_fac_bangpaichengyuan.selectedIndex
              ? WebSocketService.send({
                  c: 1219,
                  d: {
                    id: Global.bangpaiID,
                    type: 2,
                    pageNum: this.currentPage,
                  },
                })
              : 3 == this.tab_fac_bangpaichengyuan.selectedIndex &&
                WebSocketService.send({
                  c: 1219,
                  d: {
                    id: Global.bangpaiID,
                    type: 3,
                    pageNum: this.currentPage,
                  },
                }),
            void (this.spaceTime = i.getTime())
          );
      }),
      (e.prototype.onLoadBangPaiChengYuanResultFn = function (a) {
        if (0 == a.code) {
          if (this.currentPage >= 1) {
            if (0 == a.list.length) return void this.currentPage--;
            for (n = 0; n < a.list.length; n++) {
              var e = a.list[n];
              this.listArr.push(e), (this.dataSource = []);
            }
          } else (this.listArr = a.list), (this.dataSource = []);
          this.isloading = !1;
          for (var i, n = 0; n < this.listArr.length; n++) {
            var t = this.listArr[n];
            (i = {
              label_chengyuan_msg: { text: t.n + "--" + t.t },
              id: t.id,
              n: t.n,
              t: t.t,
              o: t.o,
            }),
              this.dataSource.push(i);
          }
          this.list_bangpai_chengyuan.dataSource = this.dataSource;
        }
      }),
      (e.prototype.onTabChengyuanDidClick = function (a) {
        "item0" == a.target.name
          ? WebSocketService.send({
              c: 1218,
              d: { id: Global.bangpaiID, pageNum: 0 },
            })
          : "item1" == a.target.name
          ? WebSocketService.send({
              c: 1219,
              d: { id: Global.bangpaiID, type: 1, pageNum: 0 },
            })
          : "item2" == a.target.name
          ? WebSocketService.send({
              c: 1219,
              d: { id: Global.bangpaiID, type: 2, pageNum: 0 },
            })
          : "item3" == a.target.name &&
            WebSocketService.send({
              c: 1219,
              d: { id: Global.bangpaiID, type: 3, pageNum: 0 },
            });
      }),
      (e.prototype.onLoadBangPainMemDengJiFn = function (a) {
        if (0 == a.code) {
          if (this.currentPage >= 1) {
            if (0 == a.list.length) return void this.currentPage--;
            for (n = 0; n < a.list.length; n++) {
              var e = a.list[n];
              this.listArr.push(e), (this.dataSource = []);
            }
          } else (this.listArr = a.list), (this.dataSource = []);
          this.isloading = !1;
          for (var i, n = 0; n < this.listArr.length; n++) {
            var t = this.listArr[n];
            (i = {
              label_chengyuan_msg: { text: t.n + "--" + t.t },
              id: t.id,
              n: t.n,
              t: t.t,
              o: t.o,
            }),
              this.dataSource.push(i);
          }
          this.list_bangpai_chengyuan.dataSource = this.dataSource;
        }
      }),
      (e.prototype.onLoadBangPaiManagerResultFn = function (a) {
        WebSocketService.send({
          c: 1901,
          d: { id: Global.bangpaiID, pageNum: 0 },
        });
      }),
      (e.prototype.onDidClickYaoQingAction = function (a) {
        var e;
        "btn_yaoqing_sure" == a.target.name
          ? (e = 1)
          : "btn_yaoqing_reject" == a.target.name && (e = 2),
          WebSocketService.send({
            c: 1211,
            d: {
              id: Global.bangpaiID,
              type: e,
              uid: this.listArr[this.list_fac_yaoqing.selectedIndex].id,
              i: 0,
            },
          });
      }),
      (e.prototype.onDidClickRuBangDengjiAction = function () {
        FactionSettingDialog.showFacSettingView("limitLvl");
      }),
      (e.prototype.onDidClickRYaoQingJiangLiAction = function () {
        FactionSettingDialog.showFacSettingView("yaoqingaward");
      }),
      (e.prototype.eventHandler = function (a) {}),
      (e.prototype.onLoadMySelfBangpaiDataFn = function (a) {
        0 == a.code &&
          ((this.label_fac_bangpai_minLvl.text =
            "不低于" + Global.bangpaiMinLvl + "级"),
          (Global.bangpaiMinLvl = a.data.minLvl),
          3 == a.data.mem || 4 == a.data.mem
            ? ((this.btn_fac_rubangdengji.visible = !0),
              (this.btn_fac_yaoqingjiangli.visible = !0))
            : ((this.btn_fac_rubangdengji.visible = !1),
              (this.btn_fac_yaoqingjiangli.visible = !1)));
      }),
      (e.prototype.onDidClickChengYuanDetailAction = function (a) {
        if ("" != a.target.name) {
          this.list_bangpai_chengyuan.selectedItem;
          if ("btn_bangpai_caozuo" == a.target.name) {
            var e = this.list_bangpai_chengyuan.selectedItem;
            DropDownView.openDropDownView(e);
          } else if (a.target.name) {
            var i = this.listArr[this.list_bangpai_chengyuan.selectedIndex].id;
            FriendsDetailDialog.showFriendDialog(i, !0);
          }
        }
      }),
      (e.prototype.onDidClickClose = function () {
        this.removeSelf();
      }),
      e
    );
  })(ui.FactionController.FactionManagerViewUI);
